| Conditions | 17 |
| Paths | 17 |
| Total Lines | 21 |
| Code Lines | 19 |
| Lines | 1 |
| Ratio | 4.76 % |
| Changes | 0 | ||
Complex classes like exports.toString often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
| 1 | /* |
||
| 6 | View Code Duplication | exports.toString = function (opcode) { |
|
|
|
|||
| 7 | switch (opcode) { |
||
| 8 | case 0: return 'QUERY' |
||
| 9 | case 1: return 'IQUERY' |
||
| 10 | case 2: return 'STATUS' |
||
| 11 | case 3: return 'OPCODE_3' |
||
| 12 | case 4: return 'NOTIFY' |
||
| 13 | case 5: return 'UPDATE' |
||
| 14 | case 6: return 'OPCODE_6' |
||
| 15 | case 7: return 'OPCODE_7' |
||
| 16 | case 8: return 'OPCODE_8' |
||
| 17 | case 9: return 'OPCODE_9' |
||
| 18 | case 10: return 'OPCODE_10' |
||
| 19 | case 11: return 'OPCODE_11' |
||
| 20 | case 12: return 'OPCODE_12' |
||
| 21 | case 13: return 'OPCODE_13' |
||
| 22 | case 14: return 'OPCODE_14' |
||
| 23 | case 15: return 'OPCODE_15' |
||
| 24 | } |
||
| 25 | return 'OPCODE_' + opcode |
||
| 26 | } |
||
| 27 | |||
| 49 |